package org.stratusdb.funsql.execute;


import java.util.Vector;

import org.stratusdb.error.Error;
import org.stratusdb.types.TableType;

public class SimpleProjection extends UnaryOperator {

	private static final long serialVersionUID = 7657950271889470871L;
	
	AbstractOperator child = null;
	Vector<Integer>  attr = null;
	public SimpleProjection(AbstractOperator child, Vector<Integer> attr) {
		super(child);
		this.child = child;
		this.attr = attr;
	}
	
	@Override
	public Error open() {
		return this.child.open(); 
	}

	@Override
	public TableType next() {
		return filter(this.child.next(),this.attr);
	}

	@Override
	public Error close() {
		return this.child.close();
	}

	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer("SimpleProjection : Projectionsttribute : ");
		for(Integer i : this.attr) {
			sb.append(i + " ");
		}
		return sb.toString();
	}
}
